n = int(input())
a = list(map(int, input().split()))

b = sorted(a)
s = 0
for i in range(1, n):
    s += b[i - 1] * (n - i)
print(s)
